ActiveReports Developer 7
Add Totals and Subtotals in a Data Region
See Also Support Forum
ActiveReports Developer 7 > ActiveReports Developer Guide > How To > Page Report How To > Add Totals and Subtotals in a Data Region

Glossary Item Box

You can add subtotals and grand totals in a data region to add meaning to the data it displays.

Use the steps below to learn how to set subtotals and totals in each data region. These steps assume that you have already added a Page Report template and connected it to a data source. See Adding an ActiveReport to a Project, Connect to a Data Source and Add a Dataset for more information.

Note: This topic uses examples from the tables in the Reels database. By default, in ActiveReports Developer, the Reels.mdb file is located at [User Documents folder]\ComponentOne Samples\ActiveReports Developer 7\Data\Reels.mdb.

ShowTo add Totals and Subtotals in a Table

ShowTo add a subtotals to a table group

  1. From the Visual Studio toolbox, drag and drop a Table data region onto the design surface.
  2. From the Report Explorer, drag a numeric field (like InStock) onto the detail row of the Table. This is the field for which you want to display subtotals.
  3. Follow the steps below to add groups to the Table data region.
    • Click inside the Table to reveal the row and column handles along the left and top edges.
    • Right-click in the row handles along the left edge of the table and select Insert Group.
    • In the Groups dialog that appears, set a Group on expression (like StorePrice) on which you want to group the data.
    • Click the OK button to close the dialog and add the group. A new pair of rows for group header and footer appear on the Table.
  4. From the Report Explorer, drag and drop the numeric field (like InStock) you added to the detail row in step 2, onto the GroupFooter row.
  5. Double click the textbox containing the field you just dropped onto the GroupFooter row and add a Sum function to its expression to calculate the total [for example, =Sum(Fields!InStock.Value)].
  6. Go to the Preview Tab to see the subtotals appearing below each group of data in the Table.

ShowTo add a grand total to a table

  1. Drag the numeric field (like InStock) you used to set subtotals on in the procedure above onto the Table Footer row.
  2. Double click the textbox containing the field you just dropped onto the Table Footer row and add a Sum function to its expression to calculate the total [for example, =Sum(Fields!InStock.Value)].
  3. Go to the Preview Tab and notice that at the end of the table, the Textbox from the Table Footer row supplies the grand total.

ShowTo add Totals and Subtotals in a List

ShowTo add a subtotals to a list

  1. From the Visual Studio toolbox, drag and drop a List data region onto the design surface.
  2. From the Report Explorer, drag and drop a numeric field (like Price) onto the List data region.
  3. Double click the textbox containing the field you just dropped and add a Sum function to its expression to calculate the total [for example, =Sum([Price] * [Quantity])].
    Note: If you preview the report at this point, you will notice that the field renders the grand total for the dataset after each sales amount.
  4. Follow the steps below to add detail grouping to the List data region.
    • Right-click the list and select Properties.
    • In the Detail Grouping page, select a Group on expression (like AccountNumber) on which you want to group the data.
    • Click the OK button to close the dialog and apply grouping.
  5. Go to the Preview Tab to view the report, you can see a subtotal on price for each account number.

ShowTo add a grand total to a list

  1. Drag the numeric field that shows subtotals in your list (like Price) just below the List data region.
  2. Double click the textbox containing the field you just dropped and add a Sum function to its expression to calculate the grand total [for example, =Sum([Price] * [Quantity], "List1")].
  3. Go to the Preview Tab and notice that below the List there is a Textbox that supplies the grand total.

ShowTo add Totals and Subtotals in a BandedList

ShowTo add a subtotal to a banded list

  1. From the Visual Studio toolbox, drag and drop a BandedList data region onto the design surface.
  2. From the Report Explorer, drag a numeric field (Like InStock) onto the detail band of the banded list.
  3. Follow the steps below to add groups to the BandedList data region.
    • Right-click the BandedList and select Insert Group.
    • In the Groups dialog that appears, select a Group on expression (like StorePrice) on which you want to group the data.
    • Click the OK button to close the dialog and add a group. A new pair of group bands appear on the data region.
  4. From the Report Explorer, the numeric field (like InStock) you added to the detail band in step 2, onto the GroupFooter band.
  5. Double click the textbox containing the field you just dropped and add a Sum function to its expression to calculate the subtotal[for example, =Sum(Fields!InStock.Value)].
  6. Go to the Preview Tab to view the report to see the subtotals appearing below each group of data in the BandedList.

ShowTo add a grand total to a banded list

  1. Drag the numeric field (like InStock) you used to set subtotals on in the procedure above onto the BandedListFooter band.
  2. Double click the textbox containing the field you just dropped onto the BandedListFooter band and add a Sum function to its expression to calculate the total [for example, =Sum(Fields!InStock.Value)].
  3. Go to Preview Tab and notice that at the end of the BandedList, the Textbox from the BandedListFooter band supplies the grand total.

ShowTo add Totals and Subtotals in a Matrix

ShowTo add a subtotal to a matrix group

  1. From the Visual Studio toolbox, drag and drop a Matrix data region onto the design surface.
  2. From the Report Explorer, drag and drop a field (Like Store) onto the bottom left cell of the matrix. This is the row header, and dragging a field into it automatically adds a Row Group.
  3. From the Report Explorer, drag and drop a field (Like SaleDate) onto the top right cell of the matrix. This is the column header, and automatically groups data in columns.
    Note: In this example, we have modified the value of the SalesDate field to =Fields!SaleDate.Value.Year to provide yearly data.
  4. From the Report Explorer, drag and drop a field (Like SalesAmount) onto the bottom right cell of the matrix. This is the detail data cell, and displays aggregated data for the intersection of each column and row.
  5. In the Matrix data region, click the cell containing the field you placed in the last step and go to the Properties Window.
  6. In the Properties Window, go to the Value property and set the expression for the detail cell to =Sum(Fields!SalesAmount.Value). This displays the sum of aggregated data at the intersection of each column and row.
  7. In the Matrix, right-click the column header cell and select Subtotal. A new column appears to the right with the text Total. This displays the subtotal for each row group.
  8. Right-click the row header cell and select Subtotal. A new row appears at the bottom with the text Total. This displays subtotals for each column group.  
  9. Go to the Preview tab to view the subtotals for each year.

ShowTo add a grand total to a matrix

  1. The row and columns subtotals set in the previous procedure, intersect at the rightmost cell of the Matrix that contains the grand total of the combined sales amount for years 2004 and 2005 in all the stores.
  2. Go to the Preview tab to view the result.

See Also

©2014. ComponentOne, a division of GrapeCity. All rights reserved.